<template>
    <div style="background-color: #F6F6F6;">
        <div class="headerClass">我的邀请</div>
    <div class="content">
        <div class="itemlist" v-for="item in productList" :key="item.key">
            <div class="flex-start">
                <img class="logo" :src="item.f_user.company_logo_url" alt="">
                <div class="item-div">
                    <div class="itemlist-name">{{ item.f_user.company_name }}</div>
                    <div class="itemlist-money">消费金额：￥{{item.pay_price}}</div>
                </div>
            </div>
            <div class="item-div">
                <div class="itemlist-name"><span class="itemlist-name-return">返佣：</span><span class="itemlist-name-money">￥{{ item.price }}</span></div>
                <div class="itemlist-time">{{ item.created_at }}</div>
            </div>
        </div>

        <div class="pageClass" v-if="productList.length>0">
            <div class="pageClass-first" @click="LoadFistData">首页</div>
            <div class="pageClass-Last"  @click="LoadLastData">上一页</div>
            <template v-if="totalPage < 6">
                <div :class="{'pageClass-num':true, 'active': currentPage == 1 }" @click="loadPageData(1)" v-if="totalPage >= 1" >1</div>
                <div :class="{'pageClass-num':true, 'active': currentPage == 2 }" @click="loadPageData(2)" v-if="totalPage >= 2">2</div>
                <div  :class="{'pageClass-num':true, 'active': currentPage == 3 }" @click="loadPageData(3)"  v-if="totalPage >= 3">3</div>
                <div  :class="{'pageClass-num':true, 'active': currentPage == 4 }" @click="loadPageData(4)"  v-if="totalPage >= 4">4</div>
                <div  :class="{'pageClass-num':true, 'active': currentPage == 5 }" @click="loadPageData(5)" v-if="totalPage >= 5">5</div>
                <div  :class="{'pageClass-num':true, 'active': currentPage == 6 }" @click="loadPageData(6)"  v-if="totalPage >= 6">6</div>
            </template>
            <template v-else>
                <div :class="{'pageClass-num':true, 'active': currentPage == 1 }" @click="loadPageData(1)">1</div>
                <div :class="{'pageClass-num':true, 'active': currentPage == 2 }" @click="loadPageData(2)">2</div>
                <div class="pageShenLue" >...</div>
                <div  :class="{'pageClass-num':true, 'active': currentPage == totalPage-1 }" @click="loadPageData(totalPage-1)">{{ totalPage-1 }}</div>
                <div  :class="{'pageClass-num':true, 'active': currentPage == totalPage }"  @click="loadPageData(totalPage)">{{ totalPage }}</div>
            </template>
            <div  class="pageClass-Last" @click="LoadNextData">下一页</div>
            <div  class="pageClass-first"  @click="LoadEndData">末页</div>
        </div>
        
    </div>
</div>
</template>

<script>
import { mapState } from "vuex";
import axios from "axios";

export default {
    computed: {
        ...mapState([
            "userInfo",
            'token'
        ]),
    },
    data() {
        return {
            fileList: [],
            options: [],
            productList:[],
            currentPage:1,
            totalPage:0,
        }
    },
    watch: {
    },
    created() {
        this.getProductList();
    },
    methods: {
        LoadFistData(){
            this.currentPage = 1;
            this.getProductList();
        },
        LoadLastData(){
            if(this.currentPage > 1){
                this.currentPage --;
                this.getProductList();
            }
        },
        LoadNextData(){
            if(this.currentPage < this.totalPage){
                this.currentPage ++;
                this.getProductList();
            }
        },
        LoadEndData(){
            this.currentPage = this.totalPage;
            this.getProductList();
        },
        loadPageData(val){
            this.currentPage = val;
            this.getProductList();
        },
        getProductList(){
            this.$httpApi("/api/getMyInviteList", {
                page:this.currentPage,
                limit:10,
                token: this.token
            }, "get").then(res => {
                if (res.code == 200) {
                    this.productList = res.data.list;
                    this.totalPage = Math.ceil(res.data.count / 10);
                } else {
                    alertErr(res.msg);
                }
            })
        }
    }
}
</script>

<style scoped lang="less">
.headerClass{
    padding-left: 32px;
    height: 56px;
    background: #FFFFFF;
    border-radius: 0px 0px 0px 0px;
    font-weight: bold;
    font-size: 16px;
    color: #333333;
    line-height: 56px;
    margin-bottom: 5px;
}
.content {
    padding-top: 32px;
    padding-left: 32px;
    padding-bottom: 26px;
    padding-right: 32px;
    background: #FFFFFF;

    .shuxing {
        width: 6px;
        height: 18px;
        background: #31A41B;
        border-radius: 3px 3px 3px 3px;
    }

    .flex-start {
        display: flex;
        align-items: center;
    }

    .page-title {
        font-family: PingFang SC, PingFang SC;
        font-weight: 500;
        font-size: 16px;
        color: #333333;
        margin-left: 10px;
    }

    .m-t-24 {
        margin-top: 24px;
    }

    .label {
        flex-basis: 144px;
        flex-grow: 0;
        /* 禁止放大 */
        flex-shrink: 0;
        /* 禁止缩小 */
        text-align: right;
        font-weight: 400;
        font-size: 14px;
        color: #333333;
        margin-right: 10px;
    }

    .companylogo {
        width: 120px;
        height: 74px;
    }

    .renewval {
        width: 100px;
        height: 36px;
        background: #EAF6E8;
        border: 1px solid #31A41B;
        font-weight: bold;
        font-size: 14px;
        color: #31A41B;
        text-align: center;
        line-height: 36px;
        border-radius: 20px;
        margin-top: 11px;
    }

    .name {
        text-align: right;
        font-weight: 400;
        font-size: 14px;
        color: #333333;
    }

    .red {
        color: #E5020D;
    }

    .m-l-27 {
        margin-left: 27px;
    }

    .m-l-14 {
        margin-left: 14px;
    }

    .justify-between {
        display: flex;
        justify-content: space-between;
        flex-grow: 1;
    }

    .m-t-17 {
        margin-top: 17px;
    }

    .cascaderClass {
        width: 520px;

        .el-input__inner {
            background: #FAFAFA;
        }
    }

    .btnCancel {
        width: 133px;
        height: 40px;
        background: #F5F5F5;
        border-radius: 4px 4px 4px 4px;
        border: 1px solid #D7D7D7;
        font-weight: 400;
        font-size: 14px;
        color: #666666;
        text-align: center;
        line-height: 40px;
        cursor: pointer;
    }

    .btnSave {
        width: 133px;
        height: 40px;
        background: #31A41B;
        border-radius: 4px 4px 4px 4px;
        border: 1px solid rgba(0, 0, 0, 0);
        font-weight: 400;
        font-size: 14px;
        color: #FFFFFF;
        cursor: pointer;
        text-align: center;
        line-height: 40px;
        margin-left: 12px;
    }

    .tips {
        font-weight: 400;
        font-size: 12px;
        color: #999999;
        line-height: 24px;
    }

    .fileIcon {
        width: 20px;
        height: 20px;
        margin-right: 6px;
    }

    .gouxuanIcon {
        width: 12px;
        height: 12px;
    }

    .flex-space-between {
        display: flex;
        align-items: center;
        justify-content: space-between;
    }

    .uploadRight {
        display: flex;
        height: 120px;
        align-items: flex-end;
        flex-direction: column;
        justify-content: flex-end;
    }
}
.itemlist{
    height: 109px;
    border-bottom: 1px solid #EBEEF5;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.logo{
    width: 120px;
    height: 74px;
}
.itemlist-name{
    font-weight: 500;
font-size: 16px;
color: #2C2C2C;
}
.itemlist-money{
    font-weight: 400;
font-size: 14px;
color: #747474;
line-height: 20px;
margin-top: 8px;
}
.item-div{
    margin-left: 16px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}
.itemlist-name-return{
    font-weight: 400;
font-size: 14px;
color: #747474;
line-height: 20px;
}
.itemlist-name-money{
    font-weight: 400;
font-size: 20px;
color: #FF0000;
line-height: 18px
}
.itemlist-time{
    font-weight: 400;
font-size: 14px;
color: #999999;
line-height: 20px;
text-align: left;
}


/deep/.el-upload-dragger {
    background: #FAFAFA;
    width: 200px;
    height: 120px;

    .el-icon-upload {
        font-size: 48px;
        margin: 0px;
        margin-top: 16px;
        margin-bottom: 16px;
    }

    .el-upload__text {
        color: #A2A2A2;
    }

    em {
        color: #A2A2A2;
    }
}

/deep/.el-upload-dragger:hover {
    border: 1px solid #FAFAFA;
}

input {
    flex: 2;
    height: 100%;
    padding-left: 16px;
    font-size: 14px;
    color: #000;
    background: #FAFAFA;
    border-radius: 4px 4px 4px 4px;
    border: 1px solid #E6E5E5;
    height: 40px;
    flex-basis: 520px;
    flex-grow: 0;
    flex-shrink: 0;

    &::-webkit-input-placeholder {
        font-size: 14px;
        font-family: Microsoft YaHei-Regular, Microsoft YaHei;
        font-weight: 400;
        color: #d7d7d7;
    }
}

textarea {
    flex: 2;
    height: 100%;
    padding: 16px;
    font-size: 14px;
    color: #000;
    background: #FAFAFA;
    border-radius: 4px 4px 4px 4px;
    border: 1px solid #E6E5E5;
    height: 160px;

    &::-webkit-input-placeholder {
        font-size: 14px;
        font-family: Microsoft YaHei-Regular, Microsoft YaHei;
        font-weight: 400;
        color: #d7d7d7;
    }
}

textarea:focus {
    outline: none;
    border: 1px solid #E6E5E5;
}

/deep/.el-input__inner {
    background: #FAFAFA;
}

.pageClass{
        display: flex;
        margin-top: 26px;
        justify-content: center;

        .pageClass-first{
            width: 40px;
            height: 32px;
            background: #FFFFFF;
            border-radius: 4px 4px 4px 4px;
            border: 1px solid #EEEEEE;
            font-weight: normal;
            font-size: 14px;
            color: #7A7A7A;
            line-height: 32px;
            text-align: center;
            margin-right: 16px;
            cursor: pointer;
        }

        .pageClass-Last{
            width: 69px;
            height: 32px;
            background: #FFFFFF;
            border-radius: 4px 4px 4px 4px;
            border: 1px solid #EEEEEE;
            font-weight: normal;
            font-size: 14px;
            color: #7A7A7A;
            line-height: 32px;
            text-align: center;
            margin-right:10px;
            cursor: pointer;
        }
        .pageClass-num{
            width: 32px;
            height: 32px;
            background: #FFFFFF;
            border-radius: 4px 4px 4px 4px;
            border: 1px solid #EEEEEE;
            font-weight: normal;
            font-size: 14px;
            color: #7A7A7A;
            line-height: 32px;
            text-align: center;
            margin-right: 10px;
            cursor: pointer;
        }
        .pageShenLue{
            font-weight: normal;
            font-size: 14px;
            color: #7A7A7A;
            margin-right: 10px;
        }

        .active{
            background: #31A41B;
            color: #FFF;
        }
    }
</style>